package com.haiya.memento.casestudy;

/**
 * @author qiaoguoqiang
 * 分析：
 * 假如有西施、王昭君、貂蝉、杨玉环四大美女同你相亲，你可以选择其中一位作为你的爱人；
 * 当然，如果你对前面的选择不满意，还可以重新选择，但希望你不要太花心；
 * 这个游戏提供后悔功能，用“备忘录模式”设计比较合适
 */
public class Client {
    public static void main(String[] args) {
        GirlStack girlStack = new GirlStack();
        Girl girl1 = new Girl("西施");
        Girl girl2 = new Girl("王昭君");
        Girl girl3 = new Girl("貂蝉");
        Girl girl4 = new Girl("杨玉环");

        Player player = new Player();
        player.setWife("西施");
        girlStack.push(player.createMemento());
        player.setWife("王昭君");
        girlStack.push(player.createMemento());
        player.setWife("貂蝉");
        girlStack.push(player.createMemento());
        player.setWife("杨玉环");
        girlStack.push(player.createMemento());
        player.setWife("西施");
        girlStack.push(player.createMemento());

        player.restoreMemento(girlStack.pop());
        player.restoreMemento(girlStack.pop());
        player.restoreMemento(girlStack.pop());
        player.restoreMemento(girlStack.pop());
        player.restoreMemento(girlStack.pop());
        player.restoreMemento(girlStack.pop());
    }
}
